package com.adsdk.demo.video;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.adsdk.demo.GlobalConfig;
import com.adsdk.demo.common.LogControl;
import com.heitu.s.sdk.client.AdError;
import com.heitu.s.sdk.client.AdRequest;
import com.heitu.s.sdk.client.video.FullScreenVideoAdListener;

public class FullScreenVideoActivity extends AppCompatActivity {

    static String TAG = FullScreenVideoActivity.class.getSimpleName();

    private AdRequest adRequest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(GlobalConfig.RConfig.REWARD_VIDEO_ACTIVITY_LAYOUT_ID);
        loadAd();
    }

    private void loadAd() {

        adRequest = new AdRequest.Builder(this)
                .setCodeId(getIntent().getStringExtra("codid"))
                .build();

        adRequest.loadFullScreenVideoAd(new FullScreenVideoAdListener() {

            @Override
            public void onAdError(AdError adError) {
                LogControl.i(TAG, "onAdError enter , msg = " + adError.getErrorMessage());
                FullScreenVideoActivity.this.finish();
            }

            @Override
            public void onAdClicked() {
                LogControl.i(TAG, "onAdClicked enter");
            }

            @Override
            public void onAdShow() {
                LogControl.i(TAG, "onAdShow enter");
            }

            @Override
            public void onAdVideoCompleted() {
                LogControl.i(TAG, "onAdVideoCompleted enter");
            }

            @Override
            public void onAdExposure() {
                LogControl.i(TAG, "onAdExposure enter");
            }

            @Override
            public void onAdDismissed() {
                LogControl.i(TAG, "onAdDismissed enter");
            }
        });

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LogControl.i(TAG, "onDestroy enter");
        if (adRequest != null) {
            adRequest.recycle();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onPause() {
        super.onPause();

    }
}
